﻿using System;
using System.Configuration;
using System.Windows.Forms;

namespace orderCreater
{
    public partial class Main : Form
    {
        Post_Msg Check_MyVersion(string version)
        {
            string strReturn = tool.post("http://cunwuzhi.22ca.com/admin/index.php?act=paidan_api&op=check_version", "verison=" + version);
            return JsonHelper.DeserializeJsonToObject<Post_Msg>(strReturn);
        }
        public Main()
        {
            InitializeComponent();
            Post_Msg p_msg = Check_MyVersion("1");
            if (p_msg.status == 200)
            {
                string jsonText = tool.post(ConfigurationManager.AppSettings["AddressListUrl"], ""); // 获取配送范围
                AddressRang.SendRang = JsonHelper.DeserializeJsonToList<City>(jsonText);
                AddressRang.SendRang.Insert(0, new City());
            }
            else {
                button1.Enabled = false;
                button2.Enabled = false;
                button3.Enabled = false;
                button4.Enabled = false;
                button5.Enabled = false;
                MessageBox.Show(p_msg.msg);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {

            FrmWdhOrder F1 = new FrmWdhOrder();
            F1.Show();//如果之前未打开，则打开。
        }

        private void button2_Click(object sender, EventArgs e)
        {
            FrmWdhZc F2 = new FrmWdhZc();
            F2.Show();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            Frm531Order F3 = new Frm531Order();
            F3.Show();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Frm531Zc F4 = new Frm531Zc();
            F4.Show(); 
        }

        private void button5_Click(object sender, EventArgs e)
        {
            Frm531Jf F5 = new Frm531Jf();
            F5.Show();
        }
    }
}
